import java.io.IOException;

public class K倍区间 {
    public static void main(String[] args) throws IOException {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int k = scan.nextInt();
        int[] nums = new int[n + 10];
        int[] s = new int[n + 10];
        long res = 0l;
        long []cs=new long[k];
        cs[0]=1;
        for (int i = 1; i <= n; i++) {
            nums[i] = scan.nextInt();
            s[i] = (s[i - 1] + nums[i])%k;//同模相减为k的倍数
            cs[s[i]]++;
        }
        //计算所有的组合方式
        for (int i = 0; i < k; i++) {
            res+=(cs[i]*(cs[i]-1))/2;
        }
        System.out.println(res);
    }
}
